package org.minproject.my_library_back.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.minproject.my_library_back.common.CommonResponse;
import org.minproject.my_library_back.domain.Buy;
import org.minproject.my_library_back.domain.Information;
import org.minproject.my_library_back.service.BuyService;
import org.minproject.my_library_back.mapper.BuyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Lenovo
* @description 针对表【buy】的数据库操作Service实现
* @createDate 2024-11-21 09:11:46
*/
@Service
public class BuyServiceImpl extends ServiceImpl<BuyMapper, Buy>
    implements BuyService{
    @Autowired
    private BuyMapper buyMapper;

    @Override
    public CommonResponse<List<Buy>> getBuys() throws Exception {
        List<Buy> buys = buyMapper.selectList(null);
        return CommonResponse.createForSuccess("查询成功", buys);
    }

    @Override
    public CommonResponse<List<Buy>> getBuysByUserid(int userid) throws Exception {
        QueryWrapper<Buy> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_from_id", userid);
        List<Buy> buys = buyMapper.selectList(queryWrapper);
        return CommonResponse.createForSuccess("查询成功", buys);
    }
}




